//
//  MeModifyNameViewController.m
//  DBAChain
//
//  Created by Mxionlly on 2018/9/18.
//  Copyright © 2018年 Evan. All rights reserved.
//

#import "MeModifyNameViewController.h"
#import "taskUserManagerService.h"

@interface MeModifyNameViewController ()
@property (weak, nonatomic) IBOutlet UITextField *nameField;
@property (weak, nonatomic) IBOutlet UITextField *passwordField;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *layoutToView;
@end

@implementation MeModifyNameViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"昵称修改";
    if (@available(iOS 11.0, *)) {
        self.layoutToView.constant = 10;
    } else {
        self.layoutToView.constant = 74;
    }
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self setBlackStatus:YES];
}

- (IBAction)modifyAction:(id)sender {
    if (![Check checkLenght:self.nameField.text]) {
        [DKProgressHUD showErrorWithStatus:@"请输入新昵称"];
        return;
    }
    if (![Check checkLenght:self.passwordField.text]) {
        [DKProgressHUD showErrorWithStatus:@"请输入登陆密码确认"];
        return;
    }
//    if (![self.passwordField.text isEqualToString:[UserCenter shareCenter].user.password]) {
//        [DKProgressHUD showErrorWithStatus:@"密码错误"];
//        return;
//    }
    NSMutableDictionary *dict = [NSMutableDictionary new];
    [dict setField:self.nameField.text value:@"userName"];
    [taskUserManagerService getUpdateName:dict success:^(BaseModel *response, BOOL success) {
        if (success) {
            [DKProgressHUD showSuccessWithStatus:@"修改成功"];
            [[UserCenter shareCenter] refreshProfiles:^(dataGetUserInfo *profile) {
                
            }];
            [self.navigationController popViewControllerAnimated:YES];
        }
    } failture:^(NSError *error, NSString *strDescription) {
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
